package com.common.service.system.impl;

import com.common.entity.system.DictionaryEntity;
import com.common.entity.system.DictionaryTypeEntity;
import com.common.repository.system.DictionaryTypeRepository;
import com.common.service.system.DictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author johnny
 * @create 2021-05-13 9:51 上午
 **/
@Service
@Transactional(rollbackOn = Exception.class)
public class DictionaryTypeServiceImpl implements DictionaryTypeService {

    @Autowired
    private DictionaryTypeRepository dictionaryTypeRepository;

    @Override
    public List<DictionaryTypeEntity> findAll(Specification<DictionaryTypeEntity> whereSpec) {
        return dictionaryTypeRepository.findAll(whereSpec);
    }

    @Override
    public Page<DictionaryTypeEntity> findAll(Specification<DictionaryTypeEntity> whereSpec, Pageable pageable) {
        return null;
    }

    @Override
    public List<DictionaryTypeEntity> getAll() {
        return dictionaryTypeRepository.findAll();
    }

    @Override
    public void delete(Long id) {
        dictionaryTypeRepository.deleteById(id);
    }

    @Override
    public DictionaryTypeEntity save(DictionaryTypeEntity dictionaryTypeEntity) {
        return dictionaryTypeRepository.save(dictionaryTypeEntity);
    }
}